using IRepository;
using IServices;
using SqlSugar;
using System;
using YL.Core.Dto;
using YL.Core.Entity;
using YL.Core.Entity.Common;
using YL.Utils.Extensions;
using YL.Utils.Json;
using YL.Utils.Pub;
using YL.Utils.Security;
using YL.Utils.Table;

namespace Services
{
    public class Sys_userclientServices : BaseServices<Sys_userclient>, ISys_userclientServices
    {
        private readonly SqlSugarClient _client;
        private readonly ISys_userclientRepository _UserClientRepository;

        public Sys_userclientServices(SqlSugarClient client, ISys_userclientRepository repository) : base(repository)
        {
            _client = client;
            _UserClientRepository = repository;
        }

        public string PageList(string userId)
        {
            var list = _client.Queryable<Sys_userclient,ClientInfo>
                ((s, c) => new object[] {
                   JoinType.Left,s.ClientId==c.ClientId
                 })
                 .Where(s => s.UserId == SqlFunc.ToInt64(userId))
                 .Select((s,c) => new
                 {
                     s.Id,
                     s.UserId,
                     s.ClientId,
                     c.ClientName
                 }).ToList();
            return list.JilToJson();
        }
    }
}